#include <iostream>

using namespace std;
class Singleton
{
public:
    static Singleton * getIntstence()
    {
        if(_pInstence == nullptr)
        {
            _pInstence = new Singleton(10);
        }
        return _pInstence; 

    }

    static void destory()
    {
        if(_pInstence)
        {
            delete _pInstence;
            _pInstence = nullptr;
        }
    }
    void display()
    {
        cout << "_a = " << _a << endl;
    }
    
private:
    Singleton(int a):_a(a)
    {
        cout << __FUNCTION__ << endl;
    }

    ~Singleton()
    {
        cout << __FUNCTION__ << endl;
    }
private:
    int _a;
    static Singleton * _pInstence;

};
Singleton* Singleton::_pInstence = nullptr;

int main()
{
    Singleton * p =  Singleton::getIntstence();
    p->display();
    Singleton::destory();
    return 0;
}

